import axios from 'axios'
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'

NProgress.configure({ showSpinner: false })

const http = axios.create({
  baseURL:
    'https://fc-mp-8697d378-c086-4173-ac83-6886c5caed1a.next.bspapp.com/mo-unicloud-index',
  timeout: 5000
})

http.interceptors.request.use(
  (config) => {
    NProgress.start()
    return config
  },
  (error) => {
    NProgress.done()
    console.log(error)
  }
)

http.interceptors.response.use(
  (response) => {
    NProgress.done()
    return response.data
  },
  (error) => {
    NProgress.done()
    console.log(error)
  }
)

export default http
